package com.chaoyong.higo.adapter;

import com.chaoyong.higo.R;
import com.chaoyong.higo.base.BaseAdapter;
import com.chaoyong.higo.bean.MyAccountBean;
import com.chaoyong.higo.utils.DataTimeTools;
import com.chaoyong.higo.utils.EmptyUtil;
import com.chaoyong.higo.utils.ViewHolder;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

/**
 * 我的账户
 * 
 * @author zk
 *
 */
public class AccountAdapter extends BaseAdapter<MyAccountBean.DataEntity.ListEntity> {

	/** 时间 */
	private TextView item_account_time;
	/** 类型 */
	private TextView item_account_type;
	/** 金额 */
	private TextView item_account_amount;

	public AccountAdapter(Context context) {
		super(context);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.item_my_account, null);
		}

		item_account_time = ViewHolder.get(convertView, R.id.item_account_time);
		item_account_type = ViewHolder.get(convertView, R.id.item_account_type);
		item_account_amount = ViewHolder.get(convertView, R.id.item_account_amount);

		String type = mList.get(position).getType();
		String time = mList.get(position).getTime();
		String affect_money = mList.get(position).getAffect_money();

		if (!EmptyUtil.isEmpty(type)) {
			item_account_type.setText(type + "");
		} else {
			item_account_type.setText("--");
		}
		
		if (!EmptyUtil.isEmpty(time)) {
			item_account_time.setText(DataTimeTools.time2(time));
		} else {
			item_account_time.setText("--");
		}
		
		if (!EmptyUtil.isEmpty(affect_money)) {
			item_account_amount.setText("￥"+affect_money);
		} else {
			item_account_amount.setText("--");
		}

		return convertView;
	}

}
